package com.lyf.controller.user;

import com.lyf.pojo.Category;
import com.lyf.result.Result;
import com.lyf.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "用户端分类接口")
@Slf4j
@RequestMapping("/user/category")
@RestController("userCategoryController")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @ApiOperation("查询分类")
    @GetMapping("/list")
    public Result list(@RequestParam(required = false) Integer type) {
        log.info("查询分类：{}", type);
        List<Category> list = categoryService.list(type);
        return Result.success(list);
    }
}